package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhSeries;
import com.ruoyi.xh.service.IXhSeriesService;

/**
 * 商城设置Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "商城设置Controller",value = "商城设置Controller")
@RestController
@RequestMapping("/xh/series")
public class XhSeriesController extends BaseController {

    @Autowired
    private IXhSeriesService xhSeriesService;

    /**
     * 查询商城设置列表
     */
    @PreAuthorize("@ss.hasPermi('xh:series:list')")
    @GetMapping("/list")
    @ApiOperation("查询商城设置列表")
    public TablePageDataInfo<XhSeries> list(XhSeries xhSeries) {
        return TablePageDataInfo.success(xhSeriesService.selectXhSeriesList(xhSeries));
    }

    /**
     * 获取商城设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:series:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取商城设置详细信息")
    public CommentResult<XhSeries> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhSeriesService.selectXhSeriesById(id));
    }

    /**
     * 新增商城设置
     */
    @PreAuthorize("@ss.hasPermi('xh:series:add')")
    @Log(title = "商城设置", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增商城设置")
    public CommentResult<XhSeries> add(@RequestBody XhSeries xhSeries) {
            xhSeriesService.insertXhSeries(xhSeries);
        return CommentResult.success();
    }

    /**
     * 修改商城设置
     */
    @PreAuthorize("@ss.hasPermi('xh:series:edit')")
    @Log(title = "商城设置", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改商城设置")
    public CommentResult<XhSeries> edit(@RequestBody XhSeries xhSeries) {
            xhSeriesService.updateXhSeries(xhSeries);
        return CommentResult.success();
    }

    /**
     * 删除商城设置
     */
    @PreAuthorize("@ss.hasPermi('xh:series:remove')")
    @Log(title = "商城设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除商城设置")
    public CommentResult<XhSeries> remove(@PathVariable Long[] ids) {
            xhSeriesService.deleteXhSeriesByIds(ids);
        return CommentResult.success();
    }
}
